<!DOCTYPE html>
<html>
<head>
    <title>后台</title>
    <meta charset="utf-8">
    <!-- public -->
    <link rel="stylesheet" href="<?=HW_CSS?>font.css">
    <link rel="stylesheet" href="<?=HW_CSS?>base.css">
    <link rel="stylesheet" href="<?=HW_CSS?>bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="<?=HW_CSS?>style.css">
    <link rel="stylesheet" href="<?=HW_CSS?>main_content.css">
</head>
<style>
input[type=file]{
    display: none;
}
.img-box{
    position:relative;
}
.img-box .tip{
    position: absolute;

}
.news-del{
    width: 15px;
}
</style>
<body>
    <form class="form-horizontal" action="<?=base_url().'Admin/Information/addInformation'?>" method="POST">
        <!-- toolbar_container -->
        <div id="toolbar_container">
            <div class="tb_item">
                <button type="submit" id="submitactivity">保存</button>
            </div>
            <?php if(isset($type)):?>
                <div class="tb_item">
                    <a href="<?=base_url().'Admin/Information/preview/'.$info['id']?>">返回</a>
                </div>
            <?php endif;?>
        </div>
        <!-- 基本信息 -->
        <div class="panel-group">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <a role="button" data-toggle="collapse" href="#collapseOne">
                            资讯录入
                        </a>
                    </h4>
                </div>
                <div id="collapseOne" class="panel-collapse collapse in">
                    <div class="panel-body">
                        <div class="form-group">
                            <input type='hidden' name='id' value="<?=isset($info)?$info['id']:'0'?>">
                            <label for="" class="col-sm-2 control-label">资讯标题<span>*</span>：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" placeholder="请输入少于20个汉字" name="theme" required value="<?=isset($info)?$info['theme']:''?>">
                            </div>
                        </div>
                        <div class="form-group img-box" data-num='1' id="default_img">
                            <label for="" class="col-sm-2 control-label">封面<span>*</span>：</br>推荐尺寸（375*125）</label>
                            <div class="col-sm-3">
                                <?if(isset($info) && $info['default_img']):?>
                                <div class="img_item">
                                    <img src="<?=$info['default_img']?>" />
                                    <input type="hidden" name="default_img" value="<?=$info['default_img']?>">
                                    <a class="del_img del">×</a>
                                </div>
                                <?endif;?>
                                <img src="<?=HW_IMG?>add.png" alt="" name="default_img" class='add_img'>
                                <input type="file" name="images" id="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="" class="col-sm-2 control-label">关联资讯：</label>
                            <div class="col-sm-8">
                                <button type="button" class="btn  btn-success" data-toggle="modal" data-target="#myModal" <?=(isset($info) && $count==0)?'disabled="disabled"':''?> id="addInfos">
                                    添加资讯
                                </button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="" class="col-sm-2 control-label">已关联资讯：</label>
                            <div class="col-sm-8" id="newsList">
                                <?if (isset($relation)) : foreach ($relation as $key => $v) : ?>
                                <div class="news">
                                    <label for="" class="control-label"><?=$v['theme']?></label>
                                    <img src="<?=HW_IMG?>deleteIcon.png" class="news-del" alt="" data-did="<?=$v['id']?>">
                                    <input type="hidden" name="news[]" value="<?=$v['id']?>">
                                </div>
                                <?endforeach;endif;?>
                            </div>
                        </div> 
                        <div class="form-group">
                            <label for="" class="col-sm-2 control-label">链接：</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="link" value="<?=isset($info)?$info['link']:''?>">
                            </div>
                        </div>
                        <div class="form-group u-editor">
                            <label for="" class="col-sm-2 control-label">图文介绍<span>*</span>：</label>
                            <div class="col-sm-8">
                                <script id="goods_desc" name="details" type="text/plain"><?=isset($info)?$info['content']:''?></script>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">资讯列表</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-sm-6" style="padding-left: 15px">
                            <div class="input-group">
                                <input type="text" class="form-control" placeholder="" id="searchNews">
                                <span class="input-group-btn">
                                    <button class="btn btn-default search-btn" type="button">搜索</button>
                                </span>
                            </div>
                        </div>
                    </div>
                    <div class="table-container news-list">
                        <table class="table table-bordered" id="info_table">
                            <thead>
                                <tr>
                                    <th class="col-2">选择</th>
                                    <th class="col-10">标题</th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary operation_type_btn" id="confirm">确定</button>
                </div>
            </div>
        </div>
    </div>
    <div class="mud">
        <div class="upload_success">正在上传...</div> 
    </div>
</body>
<script type="text/javascript">
    var uploadUrl = "<?=base_url().'Api/Upload/ajax_upload'?>";
    var baseUrl = "<?=base_url()?>";
    var ajaxUrl = "<?=base_url().'Admin/Information/getInfosList'?>";
    var imgUrl = "<?=HW_IMG?>";
    //可关联的资讯数量
    var count_num = "<?=isset($info)?$count:2?>";
    var relation = "<?=isset($info)?$info['relation_id']:''?>";
    var relation_id = relation.split(',');
    var infoId = "<?=isset($info)?$info['id']:0?>"
</script>
<script type="text/javascript" src="<?=HW_STA?>lib/require.js" data-main="<?=HW_STA?>module/information/infodetail.js"></script>
<script src="<?=HW_STA?>js/jquery-2.0.2.min.js"> </script>
<script type="text/javascript" src="<?=HW_UE?>ueditor.config.js"></script>
<script type="text/javascript" src="<?=HW_UE?>ueditor.all.min.js"></script> 
<script type="text/javascript" src="<?=HW_UE?>addCustomizeDialog.js"></script>
</html>